import type { RouteRecordRaw } from 'vue-router';

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    component: () => import('layouts/MainLayout.vue'),
    children: [
      {
        path: '',
        props: (route) => ({ pTab: route.query.pTab }),
        component: () => import('pages/main/MainPage.vue'),
      },
      {
        /* 标签页 */
        path: 'tag',
        props: true,
        component: () => import('src/pages/tag/TagPage.vue'),
      },
      {
        /* 标签页 */
        path: 'tag/:tagId',
        props: true,
        component: () => import('src/pages/tag/TagItemPage.vue'),
      },
      {
        /* 标签页 */
        path: 'topic',
        props: true,
        component: () => import('src/pages/topic/TopicPage.vue'),
      },
      {
        /* 标签页 */
        path: 'topic/:topicId',
        props: true,
        component: () => import('src/pages/topic/TopicItemPage.vue'),
      },
      {
        /* 分类页 */
        path: 'category/:cId',
        props: true,
        component: () => import('pages/category/CategoryPage.vue'),
      },
      {
        /* 排行页面 */
        path: 'ranking/:type',
        props: true,
        component: () => import('pages/ranking/RankingPage.vue'),
      },
      {
        /* 搜索 */
        path: 'search',
        props: (route) => ({ text: route.query.text }),
        component: () => import('pages/search/SearchPage.vue'),
      },
      {
        /* 个人设置 */
        path: 'setting',
        component: () => import('pages/setting/SettingPage.vue'),
      },
      {
        /* 个人中心 */
        path: 'personal/:uid/:tab',
        props: true,
        component: () => import('pages/personal/PersonalPage.vue'),
      },
      {
        /* 创作中心 */
        path: 'creation',
        component: () => import('pages/creation/CreationPage.vue'),
      },
      {
        path: 'blog/:artId',
        props: true,
        component: () => import('pages/article/ArticlePage.vue'),
      },
      {
        path: 'notice',
        component: () => import('pages/notice/NoticePage.vue'),
      },
      {
        path: 'chat',
        component: () => import('pages/chat/ChatPage.vue'),
      },
    ],
  },
  {
    path: '/add-blog',
    props: (route) => ({ id: route.query.id }),
    component: () => import('pages/add-article/AddBlogPage.vue'),
  },
  {
    path: '/test',
    component: () => import('pages/test/VueCropperjsPage.vue'),
  },
  {
    path: '/theme',
    component: () => import('pages/test/ThemePage.vue'),
  },
  {
    path: '/web-socket',
    component: () => import('pages/test/WebSocketPage.vue'),
  },

  // Always leave this as last one,
  // but you can also remove it
  {
    path: '/:catchAll(.*)*',
    component: () => import('pages/base/ErrorNotFound.vue'),
  },
];

export default routes;
